package com.es.service;

import com.es.event.PhoneEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * 这是商店发布的事件
 */
@Service
public class PublishEventService {
    @Autowired
    private ApplicationEventPublisher applicationEventPublisher;

    public void publishEvent(String phoneType) {
        String msg = "";
        if ("1".equals(phoneType)) {
            msg="华为到货了";
        }else if ("2".equals(phoneType)){
            msg="小米到货了";
        }else if ("3".equals(phoneType)){
            msg="vivo到货了";
        }else if ("4".equals(phoneType)){
            msg="oppo到货了";
        }else if ("5".equals(phoneType)){
            msg="魅族到货了";
        }else if ("6".equals(phoneType)){
            msg="三星到货了";
        }else if ("7".equals(phoneType)){
            msg="一加到货了";
        }else if ("8".equals(phoneType)){
            msg="苹果到货了";
        }else {
            msg="箱子是空的";
        }
        applicationEventPublisher.publishEvent(new PhoneEvent(msg));
    }
}
